package snapex.expense.mapper;

import static org.mybatis.dynamic.sql.SqlBuilder.*;
import static snapex.expense.mapper.ExpenseDetailDynamicSqlSupport.*;

import java.util.List;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.MyBatis3DeleteModelAdapter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.select.SelectDSL;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.MyBatis3UpdateModelAdapter;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import snapex.core.model.ExpenseDetail;

@Mapper
public interface HtcExpenseDetailMapper {
    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<ExpenseDetail> insertStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("ExpenseDetailResult")
    ExpenseDetail selectOne(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="ExpenseDetailResult", value = {
        @Result(column="expense_detail_id", property="expenseDetailId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="expense_id", property="expenseId", jdbcType=JdbcType.VARCHAR),
        @Result(column="occur_date", property="occurDate", jdbcType=JdbcType.VARCHAR),
        @Result(column="description", property="description", jdbcType=JdbcType.VARCHAR),
        @Result(column="currency", property="currency", jdbcType=JdbcType.CHAR),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DECIMAL),
        @Result(column="purpose_id", property="purposeId", jdbcType=JdbcType.INTEGER),
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR),
        @Result(column="list_index", property="listIndex", jdbcType=JdbcType.INTEGER)
    })
    List<ExpenseDetail> selectMany(SelectStatementProvider selectStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>> countByExample() {
        return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
                .from(expenseDetail);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
        return DeleteDSL.deleteFromWithMapper(this::delete, expenseDetail);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int deleteByPrimaryKey(String expenseDetailId_) {
        return DeleteDSL.deleteFromWithMapper(this::delete, expenseDetail)
                .where(expenseDetailId, isEqualTo(expenseDetailId_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insert(ExpenseDetail record) {
        return insert(SqlBuilder.insert(record)
                .into(expenseDetail)
                .map(expenseDetailId).toProperty("expenseDetailId")
                .map(expenseId).toProperty("expenseId")
                .map(occurDate).toProperty("occurDate")
                .map(description).toProperty("description")
                .map(currency).toProperty("currency")
                .map(amount).toProperty("amount")
                .map(purposeId).toProperty("purposeId")
                .map(id).toProperty("id")
                .map(listIndex).toProperty("listIndex")
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int insertSelective(ExpenseDetail record) {
        return insert(SqlBuilder.insert(record)
                .into(expenseDetail)
                .map(expenseDetailId).toPropertyWhenPresent("expenseDetailId", record::getExpenseDetailId)
                .map(expenseId).toPropertyWhenPresent("expenseId", record::getExpenseId)
                .map(occurDate).toPropertyWhenPresent("occurDate", record::getOccurDate)
                .map(description).toPropertyWhenPresent("description", record::getDescription)
                .map(currency).toPropertyWhenPresent("currency", record::getCurrency)
                .map(amount).toPropertyWhenPresent("amount", record::getAmount)
                .map(purposeId).toPropertyWhenPresent("purposeId", record::getPurposeId)
                .map(id).toPropertyWhenPresent("id", record::getId)
                .map(listIndex).toPropertyWhenPresent("listIndex", record::getListIndex)
                .build()
                .render(RenderingStrategy.MYBATIS3));
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<ExpenseDetail>>> selectByExample() {
        return SelectDSL.selectWithMapper(this::selectMany, expenseDetailId, expenseId, occurDate, description, currency, amount, purposeId, id, listIndex)
                .from(expenseDetail);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<ExpenseDetail>>> selectDistinctByExample() {
        return SelectDSL.selectDistinctWithMapper(this::selectMany, expenseDetailId, expenseId, occurDate, description, currency, amount, purposeId, id, listIndex)
                .from(expenseDetail);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default ExpenseDetail selectByPrimaryKey(String expenseDetailId_) {
        return SelectDSL.selectWithMapper(this::selectOne, expenseDetailId, expenseId, occurDate, description, currency, amount, purposeId, id, listIndex)
                .from(expenseDetail)
                .where(expenseDetailId, isEqualTo(expenseDetailId_))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(ExpenseDetail record) {
        return UpdateDSL.updateWithMapper(this::update, expenseDetail)
                .set(expenseDetailId).equalTo(record::getExpenseDetailId)
                .set(expenseId).equalTo(record::getExpenseId)
                .set(occurDate).equalTo(record::getOccurDate)
                .set(description).equalTo(record::getDescription)
                .set(currency).equalTo(record::getCurrency)
                .set(amount).equalTo(record::getAmount)
                .set(purposeId).equalTo(record::getPurposeId)
                .set(id).equalTo(record::getId)
                .set(listIndex).equalTo(record::getListIndex);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(ExpenseDetail record) {
        return UpdateDSL.updateWithMapper(this::update, expenseDetail)
                .set(expenseDetailId).equalToWhenPresent(record::getExpenseDetailId)
                .set(expenseId).equalToWhenPresent(record::getExpenseId)
                .set(occurDate).equalToWhenPresent(record::getOccurDate)
                .set(description).equalToWhenPresent(record::getDescription)
                .set(currency).equalToWhenPresent(record::getCurrency)
                .set(amount).equalToWhenPresent(record::getAmount)
                .set(purposeId).equalToWhenPresent(record::getPurposeId)
                .set(id).equalToWhenPresent(record::getId)
                .set(listIndex).equalToWhenPresent(record::getListIndex);
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKey(ExpenseDetail record) {
        return UpdateDSL.updateWithMapper(this::update, expenseDetail)
                .set(expenseId).equalTo(record::getExpenseId)
                .set(occurDate).equalTo(record::getOccurDate)
                .set(description).equalTo(record::getDescription)
                .set(currency).equalTo(record::getCurrency)
                .set(amount).equalTo(record::getAmount)
                .set(purposeId).equalTo(record::getPurposeId)
                .set(id).equalTo(record::getId)
                .set(listIndex).equalTo(record::getListIndex)
                .where(expenseDetailId, isEqualTo(record::getExpenseDetailId))
                .build()
                .execute();
    }

    @Generated("org.mybatis.generator.api.MyBatisGenerator")
    default int updateByPrimaryKeySelective(ExpenseDetail record) {
        return UpdateDSL.updateWithMapper(this::update, expenseDetail)
                .set(expenseId).equalToWhenPresent(record::getExpenseId)
                .set(occurDate).equalToWhenPresent(record::getOccurDate)
                .set(description).equalToWhenPresent(record::getDescription)
                .set(currency).equalToWhenPresent(record::getCurrency)
                .set(amount).equalToWhenPresent(record::getAmount)
                .set(purposeId).equalToWhenPresent(record::getPurposeId)
                .set(id).equalToWhenPresent(record::getId)
                .set(listIndex).equalToWhenPresent(record::getListIndex)
                .where(expenseDetailId, isEqualTo(record::getExpenseDetailId))
                .build()
                .execute();
    }
}